﻿Imports System.Reflection
Public Class Plugins
    Dim fs As New FS
    Dim com As New Common

    Dim plugins As New ArrayList
    Public Sub loadPlugins()
        If (fs.exists("Plugins")) Then
            For Each foundFile As String In My.Computer.FileSystem.GetFiles(fs.Startup + "Plugins")
                If (foundFile.EndsWith(".plug")) Then
                    Dim pl As String() = foundFile.Split("\")
                    Trace.WriteLine("[-] Found plugin: " + pl(pl.Length - 1))
                    Dim file As String() = System.IO.File.ReadAllLines(foundFile)
                    Dim plugindir As String = file(0)
                    Dim mainDLL As String = file(1)
                    Dim dllnamespace As String = file(3)
                    Dim plug As Assembly = Assembly.LoadFile(plugindir + "\" + mainDLL)
                    Dim main As Type = plug.GetType(dllnamespace + ".main")
                    Dim m As MethodInfo = main.GetMethod("loading")
                    Trace.WriteLine(DirectCast(m.Invoke(Nothing, New Object() {}), String))

                End If
            Next
        Else
            com.Panic("The Plugins Directory could not be found!")
        End If
    End Sub
End Class
